home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / DD3BETA1.ZIP / PACK1.PRG / TMP / DD3COMM.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-01-15  |  4.1 KB  |  193 lines

  1. unit dd3comm;
  2.  
  3. interface
  4.  
  5. uses dd3fos, dd3async;
  6.  
  7.  
  8. type
  9.   AsyncIoTypes = (Internal,Fossil);
  10. var
  11.  Local             : boolean; {Local Only Mode}
  12.  AsyncType         : AsyncIOTypes;
  13.  Com_port          : byte;
  14.  lockedbaud        : longint; {Locked BaudRate}
  15.  NonSport          : string[4]; {Non Stardard Port}
  16.  NonSIrq           : integer;
  17.  usefossil         : boolean; {Use Fossil?}
  18.  baud_rate         : longint; {Baud Rate From Drop File}
  19.  Initok            : boolean;
  20.  
  21. const
  22.   internalinsize  : word  = 256;
  23.   internaloutsize : word  = 32;
  24.  
  25. procedure AsyncOpenPort;
  26. procedure AsyncSendChar(ch: char);
  27. procedure AsyncSendStr(s : string);
  28. function AsyncReceiveChar : char;
  29. function  AsyncCarrierPresent: boolean;
  30. function  AsyncCharPresent: boolean;
  31. procedure AsyncCloseUp;
  32. procedure AsyncCloseCom(cp : byte);
  33. procedure AsyncSetBaud(n: longint);
  34. procedure AsyncSetDTR(state: boolean);
  35. procedure AsyncFlushOutput;
  36. procedure AsyncPurgeOutput;
  37. procedure AsyncSetFlow(SoftTran,Hard,SoftRecv: boolean);
  38. Procedure AsyncBufferStatus(var Insize,infree,outsize,outfree: word;
  39.                             var fossilname:string);
  40.  
  41.  
  42. implementation
  43.  
  44. procedure AsyncOpenPort;
  45. begin;
  46. case AsyncType of
  47.    Internal : begin
  48.              if NonSIrq > 0 then C_PortInt[Com_port] := NonSIrq;
  49.              {if NonSPort > '' then C_PortAddr[Com_Port] := str_to_int(NonSPort);}
  50.              OpenCom(Com_Port,InternalInSize,InternalOutSize);
  51.              ComParams(com_port,lockedbaud,8,'N',1);
  52.              AsyncPurgeOutPut;
  53.              AsyncFlushOutPut;
  54.              end;
  55.    Fossil    : begin
  56.                end;
  57. end;{case}
  58. end;
  59.  
  60. procedure AsyncSendChar(ch: char);
  61. begin;
  62. case AsyncType of
  63.    Internal :  ComWriteChW(com_port,ch);
  64.    Fossil   : ;
  65. end;
  66. end;
  67. procedure AsyncSendStr(s : string);
  68. var
  69.   i : byte;
  70. begin
  71. case asynctype of
  72.   Internal : for i := 1 to length(s) do AsyncSendChar(s[i]);
  73.   Fossil   : ;
  74. end;
  75.  
  76. end;
  77.  
  78. function AsyncReceiveChar : char;
  79. var
  80.  b: boolean;
  81.  ch : char;
  82. begin;
  83. case asynctype of
  84.   internal : begin
  85.               ch := comreadchw(com_port);
  86.               asyncreceivechar := ch;
  87.              end;
  88.   fossil   : begin
  89.              end;
  90. end;{case}
  91. end;
  92.  
  93. function AsyncCarrierPresent: boolean;
  94. begin;
  95. case asynctype of
  96.    internal : AsyncCarrierPresent:=DCDStat(com_port);
  97.    fossil   : ;
  98. end;{case}
  99. end;
  100.  
  101. function AsyncCharPresent: boolean;
  102. begin;
  103. case asynctype of
  104.    internal : asynccharpresent:=combufferleft(com_port,'I')<>c_insize[com_port];
  105.    fossil   : ;
  106. end;{case}
  107. end;
  108.  
  109.  
  110.  
  111. procedure AsyncCloseUp;
  112. begin;
  113. case asynctype of
  114.    internal : closeallcoms;
  115.    fossil   : ;
  116. end;{Case}
  117. end;
  118.  
  119. procedure AsyncCloseCom;
  120. begin;
  121. case asynctype of
  122.    internal : closecom(cp);
  123.    fossil   : ;
  124. end;{case}
  125. end;
  126.  
  127. procedure AsyncSetBaud(n: longint);
  128. var
  129.  i:byte;
  130. begin;
  131. case asynctype of
  132.  internal : comparams(com_port,n,8,'N',1);
  133.  fossil   : ;
  134. end;
  135. end;
  136.  
  137. procedure AsyncSetDTR(state: boolean);
  138. var
  139.   c : char;
  140. begin;
  141. case asynctype of
  142.   internal : SetDTR(com_port,state);
  143.   fossil   : ;
  144. end;
  145. end;
  146.  
  147. procedure AsyncFlushOutput;
  148. begin;
  149.  case asynctype of
  150.    internal : ComWaitForClear(com_port);
  151.    fossil   : ;
  152.  end;
  153. end;
  154.  
  155. procedure AsyncPurgeOutput;
  156. begin;
  157.  case asynctype of
  158.   internal : ClearCom(com_port,'O');
  159.   fossil   : ;
  160.  end;
  161. end;
  162.  
  163. procedure AsyncSetFlow(SoftTran,Hard,SoftRecv: boolean);
  164. begin;
  165.  case asynctype of
  166.    internal : begin
  167.               SetCTSMode(com_port,hard);
  168.               SetRTSMode(com_port,hard,C_RTSOn[com_port],C_RTSOff[com_port]);
  169.               end;
  170.    fossil    : ;
  171.  end; {case}
  172. end;
  173.  
  174. Procedure AsyncBufferStatus(var Insize,infree,outsize,outfree: word;
  175.                             var fossilname:string);
  176. begin;
  177. case asynctype of
  178.    internal  : begin
  179.              insize:=internalinsize;
  180.              outsize:=internaloutsize;
  181.              infree:=combufferleft(com_port,'I');
  182.              outfree:=combufferleft(com_port,'O');
  183.              end;
  184.    fossil    : ;
  185. end;{case}
  186.  
  187. end;
  188. begin;
  189.  com_port   := 0;            {Set Port to Zero}
  190.  Local      := false;        {Set to Local}
  191.  asynctype  := Internal;
  192. end.
  193.